/*
 * Copyright (c) 2022, tyustli
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-03-08     tyustli      first implementation
 */

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
    char tmp[100];
    int fd;

    printf("input your string:\r\n");
    scanf("%s", tmp);

    fd = open("test.txt", O_CREAT | O_RDWR);
    write(fd, tmp, strlen(tmp));
    close(fd);

    printf("read file :\r\n");
    fd = open("test.txt", O_RDONLY);
    read(fd, tmp, strlen(tmp));
    close(fd);
    printf("%s\r\n", tmp);

    return 0;
}

/************************ end of time ************************/
